package com.hjq.fcloud.ui.activity

import com.hjq.fcloud.R
import com.hjq.fcloud.app.AppActivity
import com.hjq.fcloud.widget.HorizontalScrollItem
import kotlinx.android.synthetic.main.activity_horizontal_view.horizontalScrollItemView
import java.util.ArrayList

/**
 * 中间嵌套水平滚动的view
 */
class HorizontalViewActivity :AppActivity(){
    override fun getLayoutId(): Int {
        return R.layout.activity_horizontal_view
    }

    override fun initView() {

    }

    override fun initData() {
        horizontalScrollItemView.setViewData(buildTestData())
    }

    private fun buildTestData(): ArrayList<ArrayList<HorizontalScrollItem>> {
        var list = ArrayList<ArrayList<HorizontalScrollItem>>()
        for (pos in 0 .. 30){
            var items = ArrayList<HorizontalScrollItem>()
            items.add(HorizontalScrollItem("序号"+pos,resources.getDimensionPixelSize(R.dimen.dp_80)))
            if(pos == 10){
                items.add(HorizontalScrollItem("材料类型材料类型材料类型材料类型材料类型"+pos,resources.getDimensionPixelSize(R.dimen.dp_120)))
            }else{
                items.add(HorizontalScrollItem("材料类型"+pos,resources.getDimensionPixelSize(R.dimen.dp_120)))

            }
            items.add(HorizontalScrollItem("材料名称"+pos,resources.getDimensionPixelSize(R.dimen.dp_120)))

            items.add(HorizontalScrollItem("规格"+pos,resources.getDimensionPixelSize(R.dimen.dp_120)))
            items.add(HorizontalScrollItem("序号"+pos,resources.getDimensionPixelSize(R.dimen.dp_80)))

            items.add(HorizontalScrollItem("材料类型"+pos,resources.getDimensionPixelSize(R.dimen.dp_120)))
            items.add(HorizontalScrollItem("材料名称"+pos,resources.getDimensionPixelSize(R.dimen.dp_120)))
            if(pos == 2){
                items.add(HorizontalScrollItem("规格2规格2规格2规格2规格2"+pos,resources.getDimensionPixelSize(R.dimen.dp_200)))
            }else{
                items.add(HorizontalScrollItem("规格"+pos,resources.getDimensionPixelSize(R.dimen.dp_200)))
            }
            list.add(items)
        }
        return list
    }
}